/**
 * Created by litch on 2017/7/11.
 */
import React from 'react'
import './left-bar.css'
import {Link,NavLink} from 'react-router-dom'
class LeftBar extends React.Component {
    constructor(props){
        super(props);
    }
    createProjectItem(flg = true) {
        if(flg){
            return (
                <li><NavLink to="/projects">项目管理</NavLink></li>
            );
        }
    }
    createUserItem(flg = true) {
        if(flg){
            return (
                <li><NavLink to="/users">用户管理</NavLink></li>
            );
        }
    }
    createKeyStoreItem(flg = true){
        if(flg){
            return (
                <li><NavLink to="/keystore">签名管理</NavLink></li>
            );
        }
    }
    createItems(permission = []){
        return (
            <ul className="nav nav-pills nav-stacked">
                <li><NavLink to="/" exact={true}>数据预览</NavLink></li>
                {this.createProjectItem(permission.includes("project:cat"))}
                {this.createUserItem(permission.includes("user:cat"))}
                {this.createKeyStoreItem(permission.includes("key:cat"))}
                <li><a href="sys.html">系统设置</a></li>
            </ul>
        );
    }
    render() {
        return (
            <nav className="leftnav" id="LeftNav">
                {this.createItems(this.props.permission)}
            </nav>
        );
    }
}
export default LeftBar;